
#include "stdafx.h"
#include "BottomBar.h"
#include "resource.h"
BottomBar::BottomBar()
: m_bTransparent( FALSE )
{
//	m_nHeight = 65;
//	m_nWidth = 480;
}
BottomBar::~BottomBar()
{
}
void BottomBar::PaintWin(HDC hdc, RECT* prcWin, RECT* prcUpdate)
{
	int height = prcWin->bottom - prcWin->top;
	int width = prcWin->right - prcWin->left;
	ImagingHelper *pImg;
	if( !m_bTransparent )
	{
		if( width < 800 )
		{
			pImg= ImagingHelper::GetImageObject( m_hInst, IDR_PNG_BOTTOM_BAR_PHOTO, true);

		}
		else
		{
			pImg = ImagingHelper::GetImageObject( GetMzResModuleHandle(), MZRES_IDR_PNG_BOTTOM_BAR_L_ALPHA, true );
		}
	}
	else
	{
		if ( width > 480 )
		{
			pImg = ImagingHelper::GetImageObject( GetMzResModuleHandle(), MZRES_IDR_PNG_BOTTOM_BAR_L_ALPHA, true );
		}
		else
		{
			pImg = ImagingHelper::GetImageObject( m_hInst, IDR_PNG_BOTTOM_BAR_TRANSPARENT_PHOTO, true );
		}
	}
	HDC picDC = pImg->GetDC();
// 	int imageWidth = pImg->GetImageWidth();
// 	if(  width > imageWidth )
// 	{   
// 		int copyWidth = width - imageWidth;
// 		int copyWidthRect = 240;
// 		int copyCount = copyWidth / copyWidthRect;
// 		if( !m_bTransparent )
// 		{
// 			BitBlt( hdc, prcWin->left, prcWin->top, imageWidth, 65, picDC, 0, 0, SRCCOPY );
// 			int copyLeft = prcWin->left + imageWidth;
// 			for ( int i = 0; i <= copyCount; ++i )
// 			{
// 				BitBlt( hdc, copyLeft, prcWin->top, copyWidthRect, 65, picDC, 3, 0, SRCCOPY );
// 				copyLeft += copyWidthRect;
// 			}
// 
// 		}
// 		else
// 		{
// 			BLENDFUNCTION bfa={AC_SRC_OVER,0,255,AC_SRC_ALPHA};
// 			AlphaBlend( hdc, prcWin->left, prcWin->top, imageWidth, 65, picDC, 0, 0, imageWidth, 65, bfa );
// 			int copyLeft = prcWin->left + imageWidth;
// 			for ( int i = 0; i <= copyCount; ++i )
// 			{
// 				//BitBlt( hdc, copyLeft, prcWin->top, copyWidthRect, m_nHeight, picDC, 3, 0, SRCCOPY );
// 				AlphaBlend( hdc, copyLeft, prcWin->top, copyWidthRect, 65, picDC, 3, 0, copyWidthRect, 65, bfa );
// 				copyLeft += copyWidthRect;
// 			}
// 		}
// 
// 	}
// 	else
// 	{
		if( !m_bTransparent )
		{
			BitBlt( hdc, prcWin->left, prcWin->top, width, height, picDC, 0, 0, SRCCOPY );
		}
		else
		{
			BLENDFUNCTION bfa={AC_SRC_OVER,0,255,AC_SRC_ALPHA};
			AlphaBlend( hdc, prcWin->left, prcWin->top, width, height, picDC, 0, 0, width, height, bfa );
		}
//	}
// 	if (IsEnableLeftArrow())
// 	{
// 		RECT rcArrow = *prcWin;
// 		rcArrow.left += 25;
// 		rcArrow.right = rcArrow.left + MzGetSysMetrics(MZ_SM_EDGE_CONTENT_H);
// 		MzDrawControl(hdc, &rcArrow, MZC_ARROW_BACK, 0,0);
//	}

}
void BottomBar::DrawTransparent( bool bTransparent /* = FALSE */ )
{
	m_bTransparent = bTransparent;
}
